package com.gateway.common.dto.convert.rule.impl;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.gateway.common.dto.convert.rule.RuleHandle;

import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * @program: api-gateway
 * @description:
 * @author: YuKai Fan
 * @create: 2025/2/14 09:24
 **/
public class TenantRuleHandle implements RuleHandle {

    /**
     * handleType
     */
    private String handleType = "default";

    /**
     * 租户id
     */
    private String tenantId;

    /**
     * appId
     */
    private String appId;

    /**
     * app密钥
     */
    private String appSecret;

    /**
     * 租户名称
     */
    private String tenantName;

    /**
     * 应用名称
     */
    private String appName;

    /**
     * 租户状态
     */
    private Boolean tenantDisable;

    /**
     * 应用状态
     */
    private Boolean appDisable;

    /**
     * 签名过期时间(秒)
     */
    private Long signatureExpireSeconds;

    /**
     * 租户过期时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date tenantExpireTime;

    /**
     * 租户域名
     */
    private Set<String> domains;

    /**
     * 字段转换
     */
    private List<Convert> converter;

    /**
     * get handleType.
     *
     * @return handleType
     */
    public String getHandleType() {
        return handleType;
    }

    /**
     * set handleType.
     *
     * @param handleType handleType
     */
    public void setHandleType(final String handleType) {
        this.handleType = handleType;
    }


    /**
     * get converter.
     *
     * @return converter
     */
    public List<Convert> getConverter() {
        return converter;
    }

    /**
     * set converter.
     *
     * @param converter converter
     */
    public void setConverter(final List<Convert> converter) {
        this.converter = converter;
    }


    public String getTenantId() {
        return tenantId;
    }

    public void setTenantId(String tenantId) {
        this.tenantId = tenantId;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getAppSecret() {
        return appSecret;
    }

    public void setAppSecret(String appSecret) {
        this.appSecret = appSecret;
    }

    public String getTenantName() {
        return tenantName;
    }

    public void setTenantName(String tenantName) {
        this.tenantName = tenantName;
    }

    public String getAppName() {
        return appName;
    }

    public void setAppName(String appName) {
        this.appName = appName;
    }

    public Long getSignatureExpireSeconds() {
        return signatureExpireSeconds;
    }

    public void setSignatureExpireSeconds(Long signatureExpireSeconds) {
        this.signatureExpireSeconds = signatureExpireSeconds;
    }

    public Date getTenantExpireTime() {
        return tenantExpireTime;
    }

    public void setTenantExpireTime(Date tenantExpireTime) {
        this.tenantExpireTime = tenantExpireTime;
    }

    public Boolean getTenantDisable() {
        return tenantDisable;
    }

    public void setTenantDisable(Boolean tenantDisable) {
        this.tenantDisable = tenantDisable;
    }

    public Boolean getAppDisable() {
        return appDisable;
    }

    public void setAppDisable(Boolean appDisable) {
        this.appDisable = appDisable;
    }

    public Set<String> getDomains() {
        return domains;
    }

    public void setDomains(Set<String> domains) {
        this.domains = domains;
    }

    public static class Convert {

        /**
         * jwt of body name.
         */
        private String jwtVal;

        /**
         * header name.
         */
        private String headerVal;

        /**
         * 是否只能有一个头数据
         */
        private boolean onlyOneHeaderVal;

        /**
         * get jwtVal.
         *
         * @return jwtVal
         */
        public String getJwtVal() {
            return jwtVal;
        }

        /**
         * set jwtVal.
         *
         * @param jwtVal jwtVal
         */
        public void setJwtVal(final String jwtVal) {
            this.jwtVal = jwtVal;
        }

        /**
         * get headerVal.
         *
         * @return headerVal
         */
        public String getHeaderVal() {
            return headerVal;
        }

        /**
         * set headerVal.
         *
         * @param headerVal headerVal
         */
        public void setHeaderVal(final String headerVal) {
            this.headerVal = headerVal;
        }

        public boolean isOnlyOneHeaderVal() {
            return onlyOneHeaderVal;
        }

        public void setOnlyOneHeaderVal(boolean onlyOneHeaderVal) {
            this.onlyOneHeaderVal = onlyOneHeaderVal;
        }

        @Override
        public String toString() {
            return "Convert{" +
                    "jwtVal='" + jwtVal + '\'' +
                    ", headerVal='" + headerVal + '\'' +
                    ", onlyOneHeaderVal=" + onlyOneHeaderVal +
                    '}';
        }
    }
}
